package com.ykt.converter;

import com.ykt.common.utils.UB;
import com.ykt.model.Ad;
import com.ykt.vo.AdVo;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: long.hua
 * @date: 2016-05-27 09:15
 * @since 1.0
 */
public class AdConverter{

    public static AdVo convert(Ad model){
        if(model == null){
            return null;
        }

        AdVo vo = new AdVo();
        BaseConverter.convert(vo, model);

        vo.setAdPic(model.getStr(Ad.ad_pic));
        vo.setAdUrl(model.getStr(Ad.ad_url));
        vo.setMarketId(UB.i(model.get(Ad.market_id)));
        vo.setStatus(UB.i(model.get(Ad.status)));
        vo.setType(model.getStr(Ad.type));
        return vo;
    }

    public static List<AdVo> convert(List<Ad> models){
        List<AdVo> vos = new ArrayList<>();
        if(models == null ||  models.isEmpty()){
            return vos;
        }

        for (Ad ad : models) {
            vos.add(convert(ad));
        }

        return vos;
    }
}
